<!DOCTYPE html>
<!--suppress ALL-->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>资料上传</title>
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" type="text/css" th:href="@{/bootstrap/bootstrap-select.css}">
    <link th:href="@{/bootstrap/bootstrap.min.css}" rel="stylesheet">
    <link th:href="@{/css/zlupdate.css}" rel="stylesheet">
    <script th:src="@{/js/jquery-1.9.1.min.js}"></script>
    <script type="text/javascript" th:src="@{/bootstrap/bootstrap-select.js}">
    </script>
    <script th:src="@{/js/address.js}"></script>
    <script th:src="@{/js/laydate.js}"></script>
    <script type="text/javascript" th:src="@{/bootstrap/bootstrap.min.js}"></script>


    <script type="text/javascript">
        document.addEventListener("DOMContentLoaded", function () {
            $('.selectpicker').selectpicker({
                'selectedText': 'cat'
            });
        });
        $(document).ready(function () {
            $(".b").fadeIn(600)
        });
        $(function () {
            var html = "";
            $("#input_city").append(html);
            $("#input_area").append(html);
            $.each(pdata, function (idx, item) {
                if (parseInt(item.level) == 0) {
                    html += "<option value=" + item.code + " >" + item.names + "</option> ";
                }
            });
            $("#input_province").append(html);

            $("#input_province").change(function () {
                if ($(this).val() == "") return;
                $("#input_city option").remove();
                $("#input_area option").remove();
                //var code = $(this).find("option:selected").attr("exid");
                var code = $(this).find("option:selected").val();
                code = code.substring(0, 2);
                var html = "<option value=''></option>";
                $("#input_area option").append(html);
                $.each(pdata, function (idx, item) {
                    if (parseInt(item.level) == 1 && code == item.code.substring(0, 2)) {
                        html += "<option value=" + item.code + " >" + item.names + "</option> ";
                    }
                });
                $("#input_city ").append(html);
            });
            $("#input_city").change(function () {
                if ($(this).val() == "") return;
                $("#input_area option").remove();
                var code = $(this).find("option:selected").val();
                code = code.substring(0, 4);
                var html = "<option value=''></option>";
                $.each(pdata, function (idx, item) {
                    if (parseInt(item.level) == 2 && code == item.code.substring(0, 4)) {
                        html += "<option value=" + item.code + " >" + item.names + "</option> ";
                    }
                });
                $("#input_area ").append(html);
            });
        });
    </script>
</head>
<b><h3 style="text-align: center;margin-top: 3%" th:text="${dc}"></h3></b>
<body class="b" style="font-size: 14px;background-color: #f9f9f9">
<input hidden="hidden" type="text" disabled value="20190626优化通用版"/>
<form style="text-align: center;margin-left: 20%;margin-right: 20%" method="post" enctype="multipart/form-data"
      action="/directionary/editor/zlpost">
    <div class="col-sm-12" th:if="${dbid} eq '16'">
        <div class="col-sm-3">
            <div class="checkbox" style="text-align: left">
                <label>
                    <input type="checkbox" value="" id="gys01" onchange="gys()">录入供应商名单
                    <input hidden="hidden" type="text" name="isgys" value="0" id="gys02">
                </label>
                <script>
                    function gys() {
                        var ischecked = $("#gys01").is(':checked')
                        if (ischecked) {
                            $("#gys02").val("1")
                        } else {
                            $("#gys02").val("0")
                        }
                    }
                </script>
            </div>
        </div>
    </div>
    <input hidden="hidden" type="text" name="dbid" th:value="${dbid}"/>
    <input type="text" name="docid" th:value="${docid}" th:if="${docid}"/>
    <div th:each="fieldsVO:${fieldsVOS}">
        <div th:if="${fieldsVO.inputType} eq '0'" style="width: 50%;float: left;">
            <div style="margin-top: 5%" class="col-sm-12">
                <div class="col-sm-3">
                    <!--<b>-->
                    <!--<span th:text="${fieldsVO.desc+':'}" style="font-size: large;margin-top: 5%"></span>-->
                    <!--</b>-->
                    <b><input disabled style="background-color: transparent;border: 0;margin-top: 1%"
                              type="text"
                              th:value="${fieldsVO.desc+':'}"/>
                    </b>
                </div>
                <div class="col-sm-9">
                    <input hidden class="text" type="text" name="Field"
                           th:value="${fieldsVO.desc+':'}"
                    />
                    <input class="form-control" type="text" name="Field"
                           th:required="${fieldsVO.isneed}==0?'false':'true'"
                           th:placeholder="${fieldsVO.isneed}==0?'选填':'必填'"/>
                    <input hidden class="text" type="text" name="Field" value="@"
                    />
                </div>
            </div>
        </div>
        <div th:if="${fieldsVO.inputType} eq '2'" style="width: 50%;float: left">
            <div style="margin-top: 5%" class="col-sm-12">
                <div class="col-sm-3">
                    <b><input disabled style="background-color: transparent;border: 0;margin-top: 1%"
                              type="text"
                              th:value="${fieldsVO.desc+':'}"/>
                    </b>
                </div>
                <div class="col-sm-9">
                    <input hidden class="text" type="text" name="Field"
                           th:value="${fieldsVO.desc+':'}"
                    />
                    <select name="Field" id="id_select" class="selectpicker bla bla bli"
                            data-live-search="true">
                        <option style="height: 20px"></option>
                        <div th:each="selectfields:${fieldsVO.valuelist}">
                            <option th:text="${selectfields}"></option>
                        </div>
                    </select>
                    <input hidden class="text" type="text" name="Field" value="@"
                    />
                </div>
            </div>
        </div>
        <div th:if="${fieldsVO.inputType} eq '4'" style="width: 50%;float: left">
            <div style="margin-top: 5%" class="col-sm-12">
                <div class="col-sm-3">
                    <b><input disabled style="background-color: transparent;border: 0;margin-top: 1%"
                              type="text"
                              th:value="${fieldsVO.desc+':'}"/>
                    </b>
                </div>
                <div class="col-sm-9">
                    <input hidden class="text" type="text" name="Field"
                           th:value="${fieldsVO.desc+':'}"
                    />
                    <input autocomplete="off" name="Field" th:id="${'time'+fieldsVOStat.index}"
                           style="width: 100%;background: #fefefe;border: 1px solid #bbb;font-size: 14px;color: #333;padding: 7px;border-radius: 3px;"
                           type="text">
                    <input hidden class="text" type="text" name="Field" value="@"
                    />
                </div>
            </div>
        </div>
        <div th:if="${fieldsVO.inputType} eq '7'" style="width: 100%;float: left">
            <div style="margin-top: 3%" class="col-sm-12">
                <div class="col-sm-3" style="text-align: left">
                    <b><input disabled style="background-color: transparent;border: 0;margin-top: 1%"
                              type="text"
                              th:value="${fieldsVO.desc+':'}"/>
                    </b>
                </div>
                <input hidden class="text" type="text" name="Field"
                       th:value="${fieldsVO.desc+':'}"
                />
                <div class="col-sm-3" style="margin-left: -13%">
                    <select required id="input_province" class="form-control">
                        <option value=""></option>
                    </select>
                </div>
                <div class="col-sm-3" style="margin-left: 6%">
                    <select required id="input_city" class="form-control">
                        <option value=""></option>
                    </select>
                </div>
                <div class="col-sm-3" style="margin-left: 6%">
                    <select required id="input_area" class="form-control"
                            th:onclick="|javascript:pro('${fieldsVO.key}')|"
                    >
                        <option value=""></option>
                    </select>
                </div>
                <input hidden th:id="${fieldsVO.key}" class="text" type="text" name="Field"/>
                <input hidden class="text" type="text" name="Field" value="@"
                />
            </div>
        </div>
        <div th:if="${fieldsVO.inputType} eq '6'" style="width: 100%;float: left">
            <div style="margin-top: 2%" class="col-sm-12">
                <div class="col-sm-3" style="text-align: left">
                    <b><input disabled style="background-color: transparent;border: 0;margin-top: 1%"
                              type="text"
                              th:value="${fieldsVO.desc+':'}"/>
                    </b>
                </div>
                <input hidden class="text" type="text" name="Field"
                       th:value="${fieldsVO.desc+':'}"
                />
                <div class="col-sm-3" style="margin-left: -13%">
                    <select name="Field" id="a"
                            onchange="change()"
                            class="selectpicker bla bla bli">
                        <option style="height: 20px"></option>
                        <span th:each="fvalues:${fieldsVO.valuelist}">
                                <option th:text="${fvalues}"></option>
                            </span>
                    </select>
                    <input hidden class="text" type="text" name="Field" value="@"
                    />
                </div>
                <span
                        th:each="son:${fieldsVO.sons}">
                        <div
                                th:id="${'a'+sonStat.index+sonStat.index}"
                                hidden="hidden" disabled="disabled"
                                class="col-sm-3" style="margin-left: 6%">
                            <input hidden class="text" type="text" name="Field"
                                   th:value="${son.desc+':'}"
                            />
                            <select name="Field"
                                    th:onchange="|javascript:change2('${'a'+sonStat.index}','${sonStat.index}')|"
                                    th:id="${'a'+sonStat.index}"
                                    class="selectpicker bla bla bli">
                                <option style="height: 20px" selected></option>
                            <span th:each="svalues:${son.valuelist}">
                                <option th:text="${svalues}"></option>
                            </span>
                            </select>
                            <input hidden class="text" type="text" name="Field" value="@"
                            />
                        </div>
                        <div th:id="${'b'+sonStat.index+gsonStat.index}"
                             hidden="hidden" disabled="disabled"
                             class="col-sm-3" style="margin-left: 6%" th:each="gson:${son.gsons}">
                            <input hidden class="text" type="text" name="Field"
                                   th:value="${gson.desc+':'}"
                            />
                            <select th:multiple="${gson.desc} eq '高校馆分类'" name="Field"
                                    th:id="${'b'+sonStat.index+gsonStat.index+gsonStat.index}"
                                    class="selectpicker bla bla bli">
                                <option style="height: 20px"></option>
                            <span th:each="gsvalues:${gson.valuelist}">
                                <option th:text="${gsvalues}"></option>
                            </span>
                            </select>
                            <input hidden class="text" type="text" name="Field" value="@"
                            />
                        </div>
                    </span>
                <input hidden th:id="${fieldsVO.key}" class="text" type="text" name="Field"/>
                <input hidden class="text" type="text" name="Field" value="@"
                />
            </div>
        </div>
    </div>




    <div class="col-sm-12">
        <div>
            <div class="col-sm-3" style="margin-top: 1%;text-align: left">
                <b><input disabled style="background-color: transparent;border: 0" type="text"
                          value="文件上传:"/>
                </b>
            </div>
            <div class="col-sm-6" style="margin-top: 1%">
                <input type="file" style="width: 100%" accept="pdf,jpg,png" onchange="checkFileType(this)" multiple
                       name="file">
            </div>
            <div class="col-sm-3" style="margin-top: 1%">
                <input disabled style="background-color: transparent;border: 0;width: 100%;color: black" type="text"
                       value="请选择ZIP,PDF格式,支持多文件上传,限制500MB内"/>
            </div>
        </div>
    </div>


    <div class="col-sm-12" style="margin-top: 5%">
        <b>
            <input class="btn btn-primary" style="border-radius:3px;width: 20%" type="button" onclick="javascript:history.go(-1)" value="返回"/>
        </b>
        <!--<input th:unless="${ss}" style="border-radius:3px;width: 15%" type="button"-->
        <!--th:onclick="|javascript:goHome('/directionary/editor/solrSearch/${dbid}/${page}')|" value="返回列表页"/>-->
        <!--<input th:if="${ss}" style="border-radius:3px;width: 15%" type="button"-->
        <!--th:onclick="|javascript:goHome('/directionary/editor/solrSearch/${dbid}/${ss}/${page}')|" value="返回列表页"/>-->
        <b>
            <input class="btn btn-primary" style="border-radius:3px;width: 20%" type="submit" value="提交资料"/>
        </b>
    </div>

    <script>
        function change() {
            var obj = document.getElementById("a"); //定位id
            var index = obj.selectedIndex; // 选中索引
            for (i = 0; i < 10; i++) {
                var e = document.getElementById("a" + i);
                if (e == null) {
                } else {
                    e.setAttribute("hidden", "hidden")
                    e.disabled = true
                }
                for (j = 0; j < 10; j++) {
                    var e4 = document.getElementById("a" + i + j);
                    if (e4 == null) {
                    } else {
                        e4.setAttribute("hidden", "hidden")
                        e4.disabled = true
                    }

                    var e2 = document.getElementById("b" + i + j);
                    if (e2 == null) {
                    } else {
                        e2.setAttribute("hidden", "hidden")
                        e2.disabled = true
                    }
                    for (k = 0; k < 10; k++) {
                        var e3 = document.getElementById("b" + i + j + k);
                        if (e3 == null) {
                        } else {
                            e3.setAttribute("hidden", "hidden")
                            e3.disabled = true
                        }
                    }
                }

            }
            var e = document.getElementById("a" + (index - 1) + (index - 1));
            e.removeAttribute("hidden", "hidden")
            e.removeAttribute("disabled", "disabled")
            e.disabled = false
            var e2 = document.getElementById("a" + (index - 1));
            e2.removeAttribute("hidden", "hidden")
            e2.removeAttribute("disabled", "disabled")
            e2.disabled = false

            //改变文件上传框
            var text = obj.options[index].text;
            var e3 = document.getElementById("yyzzFile");
            var e4 = document.getElementById("yyzzFile1");
            var e5 = document.getElementById("ptFile");
            if (text == '批发商') {
                e3.removeAttribute("hidden", "hidden");
                e4.disabled = false
                e5.removeAttribute("hidden", "hidden");
            } else {
                e3.setAttribute("hidden", "hidden");
                e4.disabled = true
                e5.setAttribute("hidden", "hidden");
            }

        };

        function change2(str, x) {
            var obj = document.getElementById(str); //定位id
            var index = obj.selectedIndex; // 选中索引
            for (i = 0; i < 10; i++) {
                for (j = 0; j < 10; j++) {
                    var e3 = document.getElementById("b" + i + j);
                    if (e3 == null) {
                    } else {
                        e3.setAttribute("hidden", "hidden")
                        e3.disabled = true
                    }
                    for (k = 0; k < 10; k++) {
                        var e2 = document.getElementById("b" + i + j + k);
                        if (e2 == null) {
                        } else {
                            e2.setAttribute("hidden", "hidden")
                            e2.disabled = true
                        }
                    }
                }
            }
            var e = document.getElementById("b" + x + (index - 1));
            if (e == null) {
            } else {
                e.removeAttribute("hidden", "hidden")
                e.disabled = false
            }
            var e2 = document.getElementById("b" + x + (index - 1) + (index - 1));
            if (e2 == null) {
            } else {
                e2.removeAttribute("hidden", "hidden")
                e2.disabled = false
            }
        };

        function goHome(url) {
            window.location.replace(url)
        };

        //限制文件上传类型
        function checkFileType(_this) {
            var $this = $(_this);
            var acceptType = $this.attr('accept');
            var selectedFile = $this.val();
            var fileType = selectedFile.substring(selectedFile.indexOf('.') + 1, selectedFile.length);
            var location = acceptType.indexOf(fileType);
            if (location > -1) {
                return true;
            } else {
                alert('请选择' + acceptType + '格式文件');
                return;
            }
        };

        function pro(str) {
            var obj1 = document.getElementById("input_province"); //定位id
            var index1 = obj1.selectedIndex; // 选中索引
            var text1 = obj1.options[index1].text; // 选中文本
            var obj2 = document.getElementById("input_city"); //定位id
            var index2 = obj2.selectedIndex; // 选中索引
            var text2 = obj2.options[index2].text; // 选中文本
            var obj3 = document.getElementById("input_area"); //定位id
            var index3 = obj3.selectedIndex; // 选中索引
            var text3 = obj3.options[index3].text; // 选中文本
            document.getElementById(str).value = text1 + "," + text2 + "," + text3
        };

        function setfj(id) {
            var v = document.getElementById(id).value;
            if (v == '') {
                document.getElementById(id + '1').value = 0;
            } else {
                document.getElementById(id + '1').value = 1
            }

        }
    </script>
    <script>
        //执行一个laydate实例
        laydate.render({
            elem: '#time1'
        });
        laydate.render({
            elem: '#time2'
        });
        laydate.render({
            elem: '#time3'
        });
        laydate.render({
            elem: '#time4'
        });
        laydate.render({
            elem: '#time5'
        });
        laydate.render({
            elem: '#time6'
        });
        laydate.render({
            elem: '#time7'
        });
        laydate.render({
            elem: '#time8'
        });
        laydate.render({
            elem: '#time9'
        });
        laydate.render({
            elem: '#time10'
        });
        laydate.render({
            elem: '#time11'
        });
        laydate.render({
            elem: '#time12'
        });
        laydate.render({
            elem: '#time13'
        });
        laydate.render({
            elem: '#time14'
        });
        laydate.render({
            elem: '#time15'
        });
    </script>

</form>
</body>
</html>